<script type="text/html" data-template-name="ha-mqtt-device_automation">
    <div class="form-row">
        <label for="node-input-server">MQTT</label>
        <select id="node-input-server"></select>
    </div>
    <div class="form-row">
        <label for="node-input-device" data-i18n="node-red-contrib-ha-mqtt/common:label.deviceName"></label>
        <select type="text" id="node-input-device" data-i18n="[placeholder]node-red-contrib-ha-mqtt/common:label.deviceName"></select>
    </div>
    <div class="form-row">
        <label for="node-input-name" data-i18n="node-red-contrib-ha-mqtt/common:label.entityName"></label>
        <input type="text" id="node-input-name" data-i18n="[placeholder]node-red-contrib-ha-mqtt/common:label.entityName">
    </div>
    <div class="form-row">
        <label for="node-input-action" data-i18n="label.type"></label>
        <input type="text" id="node-input-action" data-i18n="[placeholder]placeholder.type">
    </div>
</script>
<script type="text/javascript">
    RED.nodes.registerType('ha-mqtt-device_automation', {
        category: RED._("node-red-contrib-ha-mqtt/common:homeAssistantCategory"),
        color: '#C0DEED',
        icon: "font-awesome/fa-link",
        paletteLabel: 'Device Automation',
        defaults: {
            server: { value: "", type: "mqtt-broker", required: true },
            device: { value: "", type: "ha-mqtt-device" , required: true},
            name: { value: "", required: true },
            action: { value: "", required: true }
        },
        inputs: 1,
        outputs: 0,
        inputLabels: RED._("node-red-contrib-ha-mqtt/common:ioLabels.state"),
        label: function () {
            const { name, action } = this
            if (!name) return "device_automation"
            return `${name} ${action}`;
        }
    });

</script>